Subject: Pass empty slug field in urls
Hello.
I am trying to make this system work:
Restaurant/views.py:
class SearchRestaurantListView(ListView):
# template_name = 'restaurants/restaurantlocation_list.html'
def get_queryset(self):
print(self.kwargs)
slug = self.
urls.py:
path('restaurants//', SearchRestaurantListView.as_view())
When the slug field is empty the debugger states it couldn't find
'restaurants/', the statement above should work no? Appearently not. Please
help
--
You received this message because you are subscribed to the G
I want to make the slug field as read_only depending on the other field
value like "lock_slug".
Means There will be Two conditions.
1) When value of "lock_slug" is false then the slug field directly
prepopulated from the field "title".
prepopulated_fields =
That was it, it is working now. Thank you so much Daniel! :)
On Thursday, July 26, 2012 4:25:10 AM UTC-4, Daniel Roseman wrote:
>
> On Thursday, 26 July 2012 03:45:41 UTC+1, Matthew Meyer wrote:
>>
>> HI daniel, thanks for the reply
>>
>> After your comments, I have used ModelForm to simplify my c
On Thursday, 26 July 2012 03:45:41 UTC+1, Matthew Meyer wrote:
>
> HI daniel, thanks for the reply
>
> After your comments, I have used ModelForm to simplify my code. I have
> also achieved redirecting the desired url by using the redirect() function.
> My issues are still basically the same howe
HI daniel, thanks for the reply
After your comments, I have used ModelForm to simplify my code. I have also
achieved redirecting the desired url by using the redirect() function. My
issues are still basically the same however:
- I do not know how to tell Django to render a template at the redir
On Wednesday, 25 July 2012 02:42:45 UTC+1, Matthew Meyer wrote:
>
> Hello all,
>
> I'm trying to load the url of a model created with get_absolute_url()
> programmatically in my view. There are basically three steps I need to
> accomplish this:
>
> 1. make sure @permalink is working correctly.
Hello all,
I'm trying to load the url of a model created with get_absolute_url()
programmatically in my view. There are basically three steps I need to
accomplish this:
1. make sure @permalink is working correctly. This step I am fairly
confident I have completed. Here is the model I use:
htt
I have a slug field(let's call A) which is prepopulated from another
charfield(let's call B) and unique. On the admin page, when I want to
edit B, at the same time A, A would not be changed. I try manually, it
doesn't let me to edit it.
How can I edit unique, prepopulated slug
On Wednesday 23 September 2009 17:06:44 Justin Myers wrote:
> Two ideas:
> 1. Instead of having the slug prepopulated, override save() [1] and
> run slugify yourself.
> 2. Instead of running slugify on the name, why not just access its
> slugfield directly?
>
> HTH,
> Justin
>
> [1]
> http://doc
Two ideas:
1. Instead of having the slug prepopulated, override save() [1] and
run slugify yourself.
2. Instead of running slugify on the name, why not just access its
slugfield directly?
HTH,
Justin
[1]
http://docs.djangoproject.com/en/dev/topics/db/models/#overriding-predefined-model-methods
I have an Admin form with a slugfield prepopulated from the name of the news
item I'm creating.
In one of my templates I have a link created using the slugify filter applied
to the name of the news item.
When I create an object with a name such as "A New Story" the prepoulated field
contains "
;: ("title",)}
>
> admin.site.register(Story, StoryAdmin)
>
> Now, should I expect the slug field to get automatically populated
> with the value of title, each time an entry is saved. What is the
> expected behaviour of slug? Currently, I cannot see the value of title
rField(max_length=50, blank=False)
story = models.CharField(max_length=500, blank=False)
In admin.py
class StoryAdmin(admin.ModelAdmin):
prepopulated_fields = {"slug": ("title",)}
admin.site.register(Story, StoryAdmin)
Now, should I expect the slug field to get automatically
Malcolm Tredinnick escribió:
> The Model class calls pre_save() to work out the value to save into the
> database. That's working correctly for you, as you've noticed: the right
> value is being saved.
>
> Some Field subclasses in Django also use pre_save() as a way to
> normalise the value in th
On Thu, 2009-04-30 at 23:46 -0300, Gabriel wrote:
> I have a model with a custom field:
[...]
> class AutoSlugField(fields.SlugField):
> def __init__(self, prepopulate_from, force_update = False, *args,
> **kwargs):
> self.prepopulate_from = prepopulate_from
> self.force_updat
I have a model with a custom field:
class Project(models.Model):
slug = fields.AutoSlugField(max_length=50, unique=True,
editable=False, prepopulate_from="name", force_update=False)
name = models.CharField(unique=True, verbose_name=_('Name'),
max_length=50, help_text=_('The project name t
I'm trying to prepopulate a slug field with newforms-admin.
It works fine for the 'normal' Article model, but the inline Photo
model's slug field won't prepopulate from it's title field.
(If the code below doesn't make sense, I can paste the whole model.)
T
I'm trying to prepopulate a slug field with newforms-admin.
It works fine for the 'normal' Article model, but the inline Photo
model's slug field won't prepopulate from it's title field.
(If the code below doesn't make sense, I can paste the whole model.)
T
OK, it works... if the fields are "local" to model (not Foreign-keyed
nor M2M related). I'm gonna file documentation patch, as the docs
currently say anything on DateTimeField only.
On 5 Sie, 15:01, Jarek Zgoda <[EMAIL PROTECTED]> wrote:
> Is it possible to get slug fiel
Is it possible to get slug field prepopulated from more than one
field? The docs say that yes, but I seem to not be able to get any
prepopulation if I have prepopulated_from=('field1', 'field2') in my
model. Should I file a ticket?
I use SVN trunk (rev 5804).
I have just written a model to extend the user model a bit and now I'd
like to
add a slug field for the username, however, I can't get the slug field
to
prepopulate from the user foreign key.
A simplified version of the model would be this:
from django.db import m
Is there a simple way to add the slug field to a custom form template?
I'm using django.views.generic.create_update.create_object and my model
has a slug field. Whenever I try to add a new item to database, I
receive error saying that my "title" is similar to the on existing i
On 1/17/06, Kenneth Gonsalves <[EMAIL PROTECTED]> wrote:
>
> On Tuesday 17 Jan 2006 9:04 pm, Bryan Murdock wrote:
> > OK, so as a database dummy, how exactly is this done? Do I pipe
> > the output of 'manage.py sqlreset myapp' to psql, or is there a
> > less drastic way since I know I've only chan
On Tuesday 17 Jan 2006 9:04 pm, Bryan Murdock wrote:
> OK, so as a database dummy, how exactly is this done? Do I pipe
> the output of 'manage.py sqlreset myapp' to psql, or is there a
> less drastic way since I know I've only changed this one thing?
> I don't have any real data in the database
On 1/17/06, Kenneth Gonsalves <[EMAIL PROTECTED]> wrote:
>
> On Tuesday 17 Jan 2006 4:45 pm, Julio Nobrega wrote:
> > Restriction *is* on the database too, when you run "manage.py
> > startsql" (the command that outputs the CREATE TABLEs) you can
> > see the UNIQUE being added. But Bryan is updati
On Tuesday 17 Jan 2006 4:45 pm, Julio Nobrega wrote:
> Restriction *is* on the database too, when you run "manage.py
> startsql" (the command that outputs the CREATE TABLEs) you can
> see the UNIQUE being added. But Bryan is updating his model,
> adding the UNIQUE after the table has been create
Restriction *is* on the database too, when you run "manage.py
startsql" (the command that outputs the CREATE TABLEs) you can see the
UNIQUE being added. But Bryan is updating his model, adding the UNIQUE
after the table has been created...
On 1/17/06, Jordi Funollet <[EMAIL PROTECTED]> wrote:
>
On Tuesday 17 Jan 2006 3:53 pm, Jordi Funollet wrote:
> > Afaik Django enforces uniqueness at the application level, but
> > you could always add it to the database:
>
> Ouch. Really? So Django is assuming that we are going to work
> with their database *exclusively* through Django, and doesn't
>
On 1/17/06, Jordi Funollet <[EMAIL PROTECTED]> wrote:
> This restriction should be on database, shouldn't it?
I'd think this would run into compatibility problems with the various
supported backends. For example, SQLite supports UNIQUE, but not
FOREIGN KEY constraints (its official docs say that
Julio Nobrega dixit:
> Afaik Django enforces uniqueness at the application level, but you
> could always add it to the database:
Ouch. Really? So Django is assuming that we are going to work with their
database *exclusively* through Django, and doesn't protect us from doing silly
things to the d
Afaik Django enforces uniqueness at the application level, but you
could always add it to the database:
ALTER TABLE table ADD UNIQUE (slug)
I don't think it's a bad idea at all, it all depends ;)
On 1/16/06, Bryan Murdock <[EMAIL PROTECTED]> wrote:
>
> I think I want my model's SlugField to
I think I want my model's SlugField to be unique (let me know if this
is a Bad Idea for any reason). So I edit my model and change
slug=meta.SlugField() to slug=meta.SlugField(unique=True). Do I need
to do anything to update the database now?
Thanks,
Bryan
33 matches
Mail list logo