Re: Is it possible to save children before parents?

2017-02-12 Thread Antonis Christofides
Hello Mike,

Could you paste (the necessary part of) your models.py? Otherwise it's not easy
to understand _exactly_ what you are doing, and the exact details are playing a
role here.

Regards,

Antonis

Antonis Christofides
http://djangodeployment.com

On 02/13/2017 01:46 AM, Mike Dewhirst wrote:
> On 13/02/2017 1:12 AM, Derek wrote:
>> Mike
>>
>> Not sure I understand your scenario completely, but can you not just add a
>> post-save trigger that updates the parent field (in which the total is saved)
>> after all the other saves have happened?
>
> Derek
>
> That does not work and is one of the ways I have tried. I have also tried
> pre-saving the ingredient proportions. [1]
>
> It is all triggered by saving the mixture and all happens at the database
> level not in the browser.
>
> 1. Start with ingredients summing to 100% (A = 50% and B = 50%)
> - mixture M displays 100% in its total field
> - A displays 50% (nicely displayed via __str__(self))
> - B displays 50%
>
> 2. Adjust B to 40% and click [Save]
> - mixture gets saved and checks ingredient proportions (before or after it
> gets saved itself) and M = 100% because B has not yet been saved and the
> database still has it at 50%.
>
> 3. B gets saved as a related object and B = 40%
>
> 4. Refresh the page and predictably nothing changes because the database still
> has M = 100%, A = 50%, B = 40%.
>
> 5. Click [Save] again and the mixture checks proportions again except this
> time B = 40% so M correctly becomes 90% in the database and is correctly
> displayed.
>
> I would love to adjust Substance_Ingredients._meta.verbose_name_plural to
> display the total percentage and forget about storing it in the mixture
> altogether. I only want a "live" display of the total to assure the user about
> proportions.
>
> I have looked at adjusting verbose_name_plural in the admin but I can't figure
> out how to get access to the proportions to do the sums.
>
> I have a horrible feeling I'm going to have to allocate some really scarce
> brainspace to learning javascript. :-(
>
> Mike
>
> [1] I thought a pre-save would work but unfortunately not. If it *should* work
> I must be doing something wrong. We really need to pre-save the ingredients
> but it all happens in a single transaction which I think must succeed or be
> rolled back.
>
>
>
>
>>
>> On Sunday, 12 February 2017 00:55:52 UTC+2, Mike Dewhirst wrote:
>>
>> A mixture has a number of ingredients and the proportions should
>> (eventually) sum to 100%
>>
>> Ingredients are substances connected to the mixture - also a
>> substance
>> -  via m2m relationships. Each m2m record carries an ingredient
>> proportion value.
>>
>> If a proportion changes the sum total changes after saving the
>> mixture
>> but cannot be displayed in the parent until the following save. I
>> expect
>> I'm wrong but I cannot see any way in the Admin to update the parent
>> field in which the total is saved until after the second save.
>>
>> Is it possible to save children before the parent so the sum can be
>> evaluated, the parent field updated and then the parent saved?
>>
>> Thanks
>>
>> Mike
>>
>> Django 1.8
>> Python 2.7 and 3.5
>>
>> -- 
>> 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/4441fec6-783c-41d8-a6bf-63499cdfece2%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/370b1c12-8189-97d9-5ac6-8ca0f482a3bf%40djangodeployment.com.
For more options, visit https://groups.google.com/d/optout.


Re: Is it possible to save children before parents?

2017-02-12 Thread Mike Dewhirst

On 13/02/2017 1:12 AM, Derek wrote:

Mike

Not sure I understand your scenario completely, but can you not just 
add a post-save trigger that updates the parent field (in which the 
total is saved) after all the other saves have happened?


Derek

That does not work and is one of the ways I have tried. I have also 
tried pre-saving the ingredient proportions. [1]


It is all triggered by saving the mixture and all happens at the 
database level not in the browser.


1. Start with ingredients summing to 100% (A = 50% and B = 50%)
- mixture M displays 100% in its total field
- A displays 50% (nicely displayed via __str__(self))
- B displays 50%

2. Adjust B to 40% and click [Save]
- mixture gets saved and checks ingredient proportions (before or 
after it gets saved itself) and M = 100% because B has not yet been 
saved and the database still has it at 50%.


3. B gets saved as a related object and B = 40%

4. Refresh the page and predictably nothing changes because the database 
still has M = 100%, A = 50%, B = 40%.


5. Click [Save] again and the mixture checks proportions again except 
this time B = 40% so M correctly becomes 90% in the database and is 
correctly displayed.


I would love to adjust Substance_Ingredients._meta.verbose_name_plural 
to display the total percentage and forget about storing it in the 
mixture altogether. I only want a "live" display of the total to assure 
the user about proportions.


I have looked at adjusting verbose_name_plural in the admin but I can't 
figure out how to get access to the proportions to do the sums.


I have a horrible feeling I'm going to have to allocate some really 
scarce brainspace to learning javascript. :-(


Mike

[1] I thought a pre-save would work but unfortunately not. If it 
*should* work I must be doing something wrong. We really need to 
pre-save the ingredients but it all happens in a single transaction 
which I think must succeed or be rolled back.







On Sunday, 12 February 2017 00:55:52 UTC+2, Mike Dewhirst wrote:

A mixture has a number of ingredients and the proportions should
(eventually) sum to 100%

Ingredients are substances connected to the mixture - also a
substance
-  via m2m relationships. Each m2m record carries an ingredient
proportion value.

If a proportion changes the sum total changes after saving the
mixture
but cannot be displayed in the parent until the following save. I
expect
I'm wrong but I cannot see any way in the Admin to update the parent
field in which the total is saved until after the second save.

Is it possible to save children before the parent so the sum can be
evaluated, the parent field updated and then the parent saved?

Thanks

Mike

Django 1.8
Python 2.7 and 3.5

--
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/4441fec6-783c-41d8-a6bf-63499cdfece2%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/fe941a8f-1813-71b5-26eb-b3b8506d62da%40dewhirst.com.au.
For more options, visit https://groups.google.com/d/optout.


No module named client

2017-02-12 Thread Pravin Kumar
Hi All,

I have imported below module in views.py, but i getting error "No module 
named client".

import salt.client


i can import this module in ipython but when i import it in Django app 
view, the app getting error while loading main page itself.

*Error in web page:*

ImportError at /salt/ 

No module named client


Please help guys!!

-- 
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/3a0d8fbc-2d84-4cd3-8217-80f5c654a1e7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


django-hotsauce-0.6.5 release

2017-02-12 Thread Etienne Robillard

Hi,

I'm glad to announce the release of django-hotsauce 0.6.5.

Download location: 
http://www.isotopesoftware.ca/pub/django-hotsauce/django-hotsauce-0.6.5.tar.gz


*Whats new*

django-hotsauce:

- New ClientStorageProxy class for communication with ZODB databases.

libschevo:

- Experimental ZODB backend (ZEO.ClientStorage)

Have fun!
E

--
Etienne Robillard
tkad...@yandex.com
http://www.isotopesoftware.ca/

--
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/b953393e-1539-856d-c4f1-96830b8ef8b6%40yandex.com.
For more options, visit https://groups.google.com/d/optout.


Pagination is not showing and also not working

2017-02-12 Thread Kazi Atik
here is my views/

from django.contrib.auth.models import User

from django.core.paginator import Paginator,EmptyPage, PageNotAnInteger
from friends.models import Friendship,UserProfile
from django.http import HttpResponse, HttpResponseRedirect, Http404
from django.shortcuts import render


def dashboard(request):
if request.method == "GET":
if request.user.is_authenticated():
userp=UserProfile.objects.filter(user=request.user)
return render(request, 'dashboard.html', context={ "user": 
request.user, "userslist" : 
User.objects.all(),"userprofile":userp,"friendshiplist": 
Friendship.objects.filter(user1=request.user)})
elif request.user.is_anonymous():
return HttpResponse('Hi Guest. Please login to view your dashboard 
Login')
elif request.method=="POST":
raise Http404("dashboard does not support post")

def listing(request):
users_list = User.objects.all()
page = request.GET.get('page', 1)

paginator = Paginator(users_list, 3)
try:
user_list = paginator.page(page)
except PageNotAnInteger:
# If page is not an integer, deliver first page.
user_list = paginator.page(1)
except EmptyPage:
# If page is out of range (e.g. ), deliver last page of results.
user_list = paginator.page(paginator.num_pages)

return render(request, 'dashboard.html', {'users': user_list})


tempalates/




People you may know

Request


 {% for myuser in userslist %}
 


   
   {{ myuser.username }}
   
   
Add
   
 
 {% endfor %}

 
   {% if users.has_previous %}
 
   {% else %}
 
   {% endif %}
   {% for i in users.paginator.page_range %}
 {% if users.number == i %}
   {{ i }} (current)
 {% else %}
   {{ i }}
 {% endif %}
   {% endfor %}
   {% if users.has_next %}
 
   {% else %}
 
   {% endif %}
 






i am trying to paginate this but not getting any result


please help me 


whatsapp-8867203481







-- 
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/701eaecf-6c56-441d-bce7-2385786ffad2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: return Database.Cursor.execute(self, query, params) django.db.utils.IntegrityError: NOT NULL constraint failed: auth_user.last_login when adding a superuser

2017-02-12 Thread Adam
Hi Antonis, this is the full message including the command:

:~/udemystuff/test_project# python manage.py createsuperuser
/root/udemystuff/test_project/trydjango19/local/lib/python2.7/site-packages/django/template/utils.py:37:
 
RemovedInDjango110Warning: You haven't defined a TEMPLATES setting. You 
must do so before upgrading to Django 1.10. Otherwise Django will be unable 
to load templates.
  "unable to load templates.", RemovedInDjango110Warning)

/root/udemystuff/test_project/test_project/urls.py:11: 
RemovedInDjango110Warning: django.conf.urls.patterns() is deprecated and 
will be removed in Django 1.10. Update your urlpatterns to be a list of 
django.conf.urls.url() instances instead.
  url(r'^admin/', include(admin.site.urls)),

Username (leave blank to use 'root'): adams
Email address:
Password:
Password (again):
Traceback (most recent call last):
  File "manage.py", line 10, in 
execute_from_command_line(sys.argv)
  File 
"/root/udemystuff/test_project/trydjango19/local/lib/python2.7/site-packages/django/core/management/__init__.py",
 
line 350, in execute_from_command_line
utility.execute()
  File 
"/root/udemystuff/test_project/trydjango19/local/lib/python2.7/site-packages/django/core/management/__init__.py",
 
line 342, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
  File 
"/root/udemystuff/test_project/trydjango19/local/lib/python2.7/site-packages/django/core/management/base.py",
 
line 348, in run_from_argv
self.execute(*args, **cmd_options)
  File 
"/root/udemystuff/test_project/trydjango19/local/lib/python2.7/site-packages/django/contrib/auth/management/commands/createsuperuser.py",
 
line 52, in execute
return super(Command, self).execute(*args, **options)
  File 
"/root/udemystuff/test_project/trydjango19/local/lib/python2.7/site-packages/django/core/management/base.py",
 
line 399, in execute
output = self.handle(*args, **options)
  File 
"/root/udemystuff/test_project/trydjango19/local/lib/python2.7/site-packages/django/contrib/auth/management/commands/createsuperuser.py",
 
line 173, in handle

self.UserModel._default_manager.db_manager(database).create_superuser(**user_data)
  File 
"/root/udemystuff/test_project/trydjango19/local/lib/python2.7/site-packages/django/contrib/auth/models.py",
 
line 165, in create_superuser
return self._create_user(username, email, password, **extra_fields)
  File 
"/root/udemystuff/test_project/trydjango19/local/lib/python2.7/site-packages/django/contrib/auth/models.py",
 
line 148, in _create_user
user.save(using=self._db)
  File 
"/root/udemystuff/test_project/trydjango19/local/lib/python2.7/site-packages/django/contrib/auth/base_user.py",
 
line 74, in save
super(AbstractBaseUser, self).save(*args, **kwargs)
  File 
"/root/udemystuff/test_project/trydjango19/local/lib/python2.7/site-packages/django/db/models/base.py",
 
line 700, in save
force_update=force_update, update_fields=update_fields)
  File 
"/root/udemystuff/test_project/trydjango19/local/lib/python2.7/site-packages/django/db/models/base.py",
 
line 728, in save_base
updated = self._save_table(raw, cls, force_insert, force_update, using, 
update_fields)
  File 
"/root/udemystuff/test_project/trydjango19/local/lib/python2.7/site-packages/django/db/models/base.py",
 
line 812, in _save_table
result = self._do_insert(cls._base_manager, using, fields, update_pk, 
raw)
  File 
"/root/udemystuff/test_project/trydjango19/local/lib/python2.7/site-packages/django/db/models/base.py",
 
line 851, in _do_insert
using=using, raw=raw)
  File 
"/root/udemystuff/test_project/trydjango19/local/lib/python2.7/site-packages/django/db/models/manager.py",
 
line 122, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
  File 
"/root/udemystuff/test_project/trydjango19/local/lib/python2.7/site-packages/django/db/models/query.py",
 
line 1039, in _insert
return query.get_compiler(using=using).execute_sql(return_id)
  File 
"/root/udemystuff/test_project/trydjango19/local/lib/python2.7/site-packages/django/db/models/sql/compiler.py",
 
line 1064, in execute_sql
cursor.execute(sql, params)
  File 
"/root/udemystuff/test_project/trydjango19/local/lib/python2.7/site-packages/django/db/backends/utils.py",
 
line 79, in execute
return super(CursorDebugWrapper, self).execute(sql, params)
  File 
"/root/udemystuff/test_project/trydjango19/local/lib/python2.7/site-packages/django/db/backends/utils.py",
 
line 64, in execute
return self.cursor.execute(sql, params)
  File 
"/root/udemystuff/test_project/trydjango19/local/lib/python2.7/site-packages/django/db/utils.py",
 
line 95, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
  File 
"/root/udemystuff/test_project/trydjango19/local/lib/python2.7/site-packages/django/db/backends/utils.py",
 
line 64, in execute
return self.cursor.execute(sql, params)
  File 

Re: Does anyone know a Django-based website containing Member registration with membership management, Articles and Forum?

2017-02-12 Thread Rahul P


On Saturday, 4 February 2017 20:05:05 UTC+5:30, skyppy wrote:
>
> I would like to see some Django-based websites with Member registration, 
> membership management and Membership profiles, Articles and Forum. I've the 
> idea that all of those things are possible with Django, but up until know I 
> couldn't find beautifully crafted Articles (like Blog posts) and Discussion 
> Foruns based on Django.
>
> Could you please provide me some links for websites like those I'm trying 
> to look for or at least similar on some functionalities.
>

Check this out
https://www.shuup.com/en/blog/25-of-the-most-popular-python-and-django-websites/

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


Re: Is it possible to save children before parents?

2017-02-12 Thread Derek
Mike

Not sure I understand your scenario completely, but can you not just add a 
post-save trigger that updates the parent  field (in which the total is 
saved) after all the other saves have happened?

On Sunday, 12 February 2017 00:55:52 UTC+2, Mike Dewhirst wrote:
>
> A mixture has a number of ingredients and the proportions should 
> (eventually) sum to 100% 
>
> Ingredients are substances connected to the mixture - also a substance 
> -  via m2m relationships. Each m2m record carries an ingredient 
> proportion value. 
>
> If a proportion changes the sum total changes after saving the mixture 
> but cannot be displayed in the parent until the following save. I expect 
> I'm wrong but I cannot see any way in the Admin to update the parent 
> field in which the total is saved until after the second save. 
>
> Is it possible to save children before the parent so the sum can be 
> evaluated, the parent field updated and then the parent saved? 
>
> Thanks 
>
> Mike 
>
> Django 1.8 
> Python 2.7 and 3.5 
>
>

-- 
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/4441fec6-783c-41d8-a6bf-63499cdfece2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: return Database.Cursor.execute(self, query, params) django.db.utils.IntegrityError: NOT NULL constraint failed: auth_user.last_login when adding a superuser

2017-02-12 Thread Antonis Christofides
Hello, please show the full traceback.

Antonis Christofides
http://djangodeployment.com

On 02/12/2017 06:58 AM, Adam wrote:
> Hi everyone, 
>
> I'm super new to django, I tried to add a superuser and this is the error I 
> got: 
>
>
> File
> "/root/udemystuff/test_project/trydjango19/local/lib/python2.7/site-packages/django/db/backends/sqlite3/base.py",
> line 323, in execute
> return Database.Cursor.execute(self, query, params)
> django.db.utils.IntegrityError: NOT NULL constraint failed: 
> auth_user.last_login
>
>
> I tried to run migrate and did also migrate --fake but it did not resolve the
> issue, any clues what could be my issue ?
>
> Cheers everyone,
> -- 
> 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/96c76c04-6277-446e-8488-90ba22fa548a%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/b945a18a-9276-b7b5-d33d-da17de398117%40djangodeployment.com.
For more options, visit https://groups.google.com/d/optout.


return Database.Cursor.execute(self, query, params) django.db.utils.IntegrityError: NOT NULL constraint failed: auth_user.last_login when adding a superuser

2017-02-12 Thread Adam
Hi everyone, 

I'm super new to django, I tried to add a superuser and this is the error I 
got: 


File 
"/root/udemystuff/test_project/trydjango19/local/lib/python2.7/site-packages/django/db/backends/sqlite3/base.py",
 
line 323, in execute
return Database.Cursor.execute(self, query, params)
django.db.utils.IntegrityError: NOT NULL constraint failed: 
auth_user.last_login


I tried to run migrate and did also migrate --fake but it did not resolve 
the issue, any clues what could be my issue ?

Cheers everyone,

-- 
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/96c76c04-6277-446e-8488-90ba22fa548a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: class bade view

2017-02-12 Thread ludovic coues
We call it function based view. Method are function attached to an object.

As far as I know, there is no plan to remove function based view.



But in my opinion, you should definitely have a look at class based
view. They really shine in common task.

An example, a view to create an object will take something like 10 to
20 lines of code in function based view. You need to treat the case of
showing the form, handling a valid form, handling a form with
validation error.
With class based view, that's 4 lines. Declare a class inheriting from
UpdateView, define the url to redirect to in case of valid form, which
model to update and which field to update.

So sure, they are redundant. But they save a lot of time, make the
code easier to understand and prevent error in commons case.

2017-02-11 23:16 GMT+01:00  :
> hello
>
> i have learned some django and but i write my views in method base views.
>
> i dont now how to use class base views and i am not interested to learn
> class base views
> because i think it's redundant .
>
> do i have to learn it ?
> i that possible method base views will remove in next version of django?
> 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/8c81adf0-06e3-400c-beb3-07155e26fa25%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



-- 

Cordialement, Coues Ludovic
+336 148 743 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/CAEuG%2BTYWoywm5FvkpfVg%3D1J5BUkqcn0KwOKvweOHx8mS%3DfF_tw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django doesn't load CSS

2017-02-12 Thread ludovic coues
Have you tried to run manage.py collectstatic ?
The devserver with debug serve static file from each app, but it
doesn't do it without debug.
The idea is that static files should be served directly by your server
or with a CDN and not requiring any CPU time from django.

2017-02-11 22:37 GMT+01:00 Rafał eM :
> Guys,
>
> Following tutorial from djangoproject.com I stuck with loading CSS to the
> site.
>
> Django 1.10
>
> settings.py:
> STATIC_URL = '/static/'
>
> base.html:
> 
>
>  the path to blog.css in my project is:
> blog/static/blog/css/blog.css
>
> it works perfectly fine when running django webserver on my local machine (#
> python manage.py runserver), however when putting files on the server it
> doesn't work anymore. By opening source of the site I can see:
> 
>
> I've found out the workaround - hardcoding the css path to:
> 
>
> It works, but I'd like to do that in "official" way - using the static tags
> - "{% static 'css/blog.css' %}"
>
> I've tried by changing and/or setting STATIC_URL, STATIC_ROOT,
> STATICFILES_DIRS and STATICFILES_FINDERS,  but without any success story.
> Does any of you have any idea on how to get it working?
>
> --
> 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/eba57537-c217-49ff-b3e5-ff65796bb8d5%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



-- 

Cordialement, Coues Ludovic
+336 148 743 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/CAEuG%2BTY%3Dh5edtMK0n%2BgeOxwCdFXaTV2X_29XK9tdZO6dyM7OLw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: file fields

2017-02-12 Thread ludovic coues
Ok, sorry for the delayed response, I was a bit busy the last few days

The error is the location argument for your FileSystemStorage. It
should be a string and you are passing a tuple. That's why you get a
TypeError with illegal type for parameter.
Have you tried to entirely remove the storage argument to your
models.FileField ? By default, upload_to refer to a subfolder of
MEDIA_ROOT, which you can specify in you settings.py file.

2017-02-09 1:02 GMT+01:00 ايهاب توفيق :
> hi this backtrace
>
> Performing system checks...
>
> System check identified no issues (0 silenced).
> Unhandled exception in thread started by  check_errors..wrapper at 0x036B8588>
> Traceback (most recent call last):
>   File
> "C:\Users\e.bugaighis\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\utils\autoreload.py",
> line 226, in wrapper
> fn(*args, **kwargs)
>   File
> "C:\Users\e.bugaighis\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\core\management\commands\runserver.py",
> line 117, in inner_run
> self.check_migrations()
>   File
> "C:\Users\e.bugaighis\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\core\management\commands\runserver.py",
> line 163, in check_migrations
> executor = MigrationExecutor(connections[DEFAULT_DB_ALIAS])
>   File
> "C:\Users\e.bugaighis\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\db\migrations\executor.py",
> line 20, in __init__
> self.loader = MigrationLoader(self.connection)
>   File
> "C:\Users\e.bugaighis\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\db\migrations\loader.py",
> line 49, in __init__
> self.build_graph()
>   File
> "C:\Users\e.bugaighis\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\db\migrations\loader.py",
> line 170, in build_graph
> self.load_disk()
>   File
> "C:\Users\e.bugaighis\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\db\migrations\loader.py",
> line 105, in load_disk
> migration_module = import_module("%s.%s" % (module_name,
> migration_name))
>   File
> "C:\Users\e.bugaighis\AppData\Local\Programs\Python\Python35-32\lib\importlib\__init__.py",
> line 126, in import_module
> return _bootstrap._gcd_import(name[level:], package, level)
>   File "", line 986, in _gcd_import
>   File "", line 969, in _find_and_load
>   File "", line 958, in _find_and_load_unlocked
>   File "", line 673, in _load_unlocked
>   File "", line 665, in exec_module
>   File "", line 222, in
> _call_with_frames_removed
>   File
> "C:\Users\e.bugaighis\Desktop\ehab\test001\migrations\0007_auto_20161213_1444.py",
> line 9, in 
> class Migration(migrations.Migration):
>   File
> "C:\Users\e.bugaighis\Desktop\ehab\test001\migrations\0007_auto_20161213_1444.py",
> line 19, in Migration
> field=models.FileField(blank=True, null=True,
> storage=django.core.files.storage.FileSystemStorage(location=('C:\\Users\\e.bugaighis\\Desktop\\ehab\\media',)),
> upload_to='/media/'),
>   File
> "C:\Users\e.bugaighis\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\core\files\storage.py",
> line 185, in __init__
> self.location = abspathu(self.base_location)
>   File
> "C:\Users\e.bugaighis\AppData\Local\Programs\Python\Python35-32\lib\ntpath.py",
> line 535, in abspath
> path = _getfullpathname(path)
> TypeError: _getfullpathname: illegal type for path parameter
>
> بتاريخ الخميس، 26 يناير، 2017 1:04:28 ص UTC+2، كتب ايهاب توفيق:
>>
>> I am new in django and to know how to use multiple file field in the same
>> model can any one 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/99a9c6a2-2019-4b71-8542-1710bb9ebff7%40googlegroups.com.
>
> For more options, visit https://groups.google.com/d/optout.



-- 

Cordialement, Coues Ludovic
+336 148 743 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/CAEuG%2BTZX7Q10UdQXi%3DWdyxAwxo2_84JRtagY2Sp_FyegF%3DKc1Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django doesn't load CSS file using static constant

2017-02-12 Thread Mike Dewhirst

On 02/12/2017 12:40 AM, Rafał eM wrote:

Guys,
I'm following one of the Django tutorials but currently stuck with a 
problem. When running django webserver on my local machine everything 
works fine, but when upload the project to the server it doesn't read 
css file anymore.


settings.ps:
|
STATIC_URL ='/static/'
|

base.html:
|
{%load static%}...

|

The path to the file is:
|
blog/static/blog/css/blog.css
|

Regardles of configuration I use, I always see in the source:
|

Re: No installed app with label 'province'.

2017-02-12 Thread Derek
Not preaching (as I often fall into this trap myself) but just copy 
from others' examples, without understanding what is the intent of the 
code, can lead to problems.

In this case, the docs are useful (for understanding how to construct the 
`app_label`, for example):

https://docs.djangoproject.com/en/1.10/ref/models/options/

And also this link:

https://docs.djangoproject.com/en/1.10/topics/db/models/#meta-options

where it explicitly says:

"... adding class Meta to a model is completely optional."

so, if you find you need this, it may because something else has not been 
done correctly.

On Saturday, 11 February 2017 13:27:24 UTC+2, Gerald Brown wrote:
>
> Finally solved the problem!!!
> At the end of each Model definition I had added:
> class Meta:
> managed = True
> db_table = 'refer'
> app_label = 'Refer'
>
> I then commented those lines out and then the program worked like it 
> should. I saw another post where they had put those variables as part of an 
> "options" statement.
>
> I was getting other errors when I did not have the "app_label" line so 
> that is why I added that.
>  
>
> On Wednesday, February 8, 2017 at 7:09:12 AM UTC+8, Gerald Brown wrote:
>>
>> I have just started an app on Ubuntu 16.04 Server using Python 3.5 and 
>> Django 1.10.5.
>>
>> When I do "@admin.register(Province)" in my admin.py file I get the error 
>> that is the subject of this post.
>>
>> Of course there is NO app with label of 'province' as that is the label 
>> of a 'Model'.
>>
>> Why is Django trying to register an app instead of the Model?
>>
>> Thanks,
>>
>> Gerald
>>
>>
>>

-- 
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/ebd97fee-714f-4feb-bc26-d5ddf2918d79%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django doesn't load CSS file using static constant

2017-02-12 Thread Antonis Christofides
Hello,

While it's not easy to know exactly what the problem is in your case without
more information (such as the web server's configuration), a general
understanding of Django's static files in production can help, and to this end
I've made a schematic that you may find useful, at
https://djangodeployment.com/2016/11/21/how-django-static-files-work-in-production/.

Regards,

Antonis

Antonis Christofides
http://djangodeployment.com


On 02/12/2017 12:40 AM, Rafał eM wrote:
> Guys,
>
> I'm following one of the Django tutorials but currently stuck with a problem.
> When running django webserver on my local machine everything works fine, but
> when upload the project to the server it doesn't read css file anymore.
>
> settings.ps:
> |
> STATIC_URL ='/static/'
> |
>
> base.html:
> |
> {%load static%}...
> |
>
> The path to the file is:
> |
> blog/static/blog/css/blog.css
> |
>
> Regardles of configuration I use, I always see in the source:
> |
>